﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp;
using Volo.Abp.Domain.Values;

namespace Mozhi.Abp.Domain.AuthorCenter
{
    public class Department : ValueObject
    {
        [JsonProperty]
        public virtual Guid Id { get; protected set; }

        [JsonProperty]
        public virtual string Code { get; protected set; }

        [JsonProperty]
        public virtual string Name { get; protected set; }

        [JsonProperty]
        public virtual bool Activated { protected set; get; }

        [JsonProperty]
        public virtual Guid? ParentId { get; protected set; }

        public virtual void Validate()
        {
            if (!Activated)
                throw new UserFriendlyException($"部门:{Code}-{Name}已禁用", "100000");
        }

        public Department(Guid id, string code, string name ,bool activated)
        {
            Id = id;
            Code = code;
            Name = name;
            Activated = activated;
        }

        protected override IEnumerable<object> GetAtomicValues()
        {
            throw new NotImplementedException();
        }
    }
}
